{include file='common/head.html'}

<div class="layui-body">
	<div class="layui-tab layui-tab-brief" lay-filter="tab">
	  <ul class="layui-tab-title">
	    <li class="layui-this" lay-id="t1"><a href="{url./admin/Syslog/index}">系统日志</a></li>
	    <li lay-id="t2"><a href="{url./admin/Loginlog/index}">登录日志</a></li>
	  </ul>
	  <div class="layui-tab-content">
	  	   <div class="layui-tab-item layui-show">
		  	   	<table class="layui-table mt0">
	            	<thead>
	                    <tr>
	                        <th>序号</th>
	                        <th>事件内容</th>
	                        <th>用户IP</th>
	                        <th>操作系统</th>
	                        <th>浏览器</th>
	                        <th>用户名</th>
	                        <th>时间</th>
	                    </tr>
	                </thead>
	                <tbody>
	                    {foreach $syslogs(key,value,num)}
	                    <tr>
	                        <td>[num]</td>
	                        <td>[value->event]</td>
	                        <td><a href="http://ip.taobao.com/ipSearch.html?ipAddr={fun=long2ip($value->user_ip)}" target="_blank" title="点击查看归属地">{fun=long2ip($value->user_ip)}</a></td>
	                        <td>[value->user_os]</td>
	                        <td>[value->user_bs]</td>
	                        <td>[value->create_user]</td>
	                        <td>[value->create_time]</td>
	                    </tr>
	                    {/foreach}
	                </tbody>
	            </table>
	            {if(session('ucode')==10001 && [$syslogs])}
	            	<a href="javascript:clear_syslog('{url./admin/Syslog/clear}','确认要清空日志吗?')" class="layui-btn layui-btn-sm">清空日志</a>
	            {/if}
	            <div class="page">{$pagebar}</div>
	  	   </div>
	  </div>
	</div>	
</div>
<script type="text/javascript">
// 清除日志
function clear_syslog(url,title){
      layer.confirm(title, {icon: 3, title:'提示'}, function(index){
          //do something
          $.ajax({
              url:url,
              success:function(data){
                  var data = JSON.parse(data);
                  if (data.code == 0) {
                  	layer.msg(data.data, {
                  	    icon: 1,
                  	    time: 1000 //1秒关闭（如果不配置，默认是3秒）
                  	},function(){
                  		window.location.reload();
                  	    return true;
                  	});
                  } else {
                      layer.msg(data.data, {icon: 2,time: 1000});
                  }
              }
          });
          layer.close(index);
      });
  }  
</script>
{include file='common/foot.html'}